package com.linkhub.oms.admin.modules.pickuporder.domain.vo;

import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkhub.oms.common.util.QtBeanUtil;
import com.linkhub.oms.common.util.QtStreamUtil;
import com.linkhub.oms.entity.PickUpGoodsOrderEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Description: PickUpOrderDetailVO
 * @Author: echo
 * @Date: 2024/5/2 09:42
 * @Version: 1.0
 */
@Data
@ApiModel(value = "PickUpOrderDetailVO")
public class PickUpOrderDetailVO implements Serializable {

    @ApiModelProperty(value = "userId")
    private String userId;

    @ApiModelProperty(value = "入库单号（提货id）")
    private String sysEntryOrderCode;

    @ApiModelProperty(value = "提货费")
    private String takeDeliveryCost;

    @ApiModelProperty(value = "实际提货费，员工侧才有数据")
    private String realTakeDeliveryCost;

    @ApiModelProperty(value = "提货商品")
    private List<EntryOrderLineVO> orderLines;

    @ApiModelProperty(value = "预计提货时间")
    @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    private LocalDateTime predictDeliveryTime;

    @ApiModelProperty(value = "预计到货日期")
    @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    private LocalDateTime predictArrivalTime;

    @ApiModelProperty(value = "仓库入库时间")
    @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    private LocalDateTime storageTime;

    @ApiModelProperty(value = "提货状态：1-待审核；2-生产中；3-运输中；4-入库中；5-已入库（已上架）；6-已取消;7-已完成")
    private Integer state;

    @ApiModelProperty(value = "系统供应商id")
    private String sysSupplierId;

    @ApiModelProperty(value = "提货方式：1-供应商自送；2-shipO提货")
    private Integer deliveryMethod;

    @ApiModelProperty(value = "物流公司")
    private String logisticsCompany;

    @ApiModelProperty(value = "物流单号")
    private String logisticsOddNumber;

    @ApiModelProperty(value = "附件名称")
    private String attachmentName;

    @ApiModelProperty(value = "文件url")
    private String attachmentUrl;

    @ApiModelProperty(value = "司机名字")
    private String driverName;

    @ApiModelProperty(value = "司机电话")
    private String driverPhone;

    @ApiModelProperty(value = "车牌")
    private String licensePlate;

    @ApiModelProperty(value = "车型号")
    private String typeOfCar;


    public static PickUpOrderDetailVO convert(PickUpGoodsOrderEntity entity) {
        PickUpOrderDetailVO vo = new PickUpOrderDetailVO();
        QtBeanUtil.copyProperties(entity, vo, CopyOptions.create().ignoreCase().ignoreError());
        vo.setOrderLines(QtStreamUtil.map(entity.getOrderLines(), EntryOrderLineVO::convert));
        vo.setState(entity.getState().getCode());
        vo.setDeliveryMethod(entity.getDeliveryMethod().getCode());
        vo.setAttachmentUrl(entity.getAttachmentOssKey());

        return vo;
    }


}
